/*
 * Created on 2005-3-12
 */
package com.hd123.rumba.user;

import com.hd123.rumba.cartridge.FVRumbaSystem;
import com.hd123.rumba.exception.StringTooLongException;
import com.hd123.rumba.runtime.VersionedPersistent;

/**
 * @author caili
 */
public class Permission extends VersionedPersistent implements IPermission {

  /** @deprecated */
  public static final String CAPTION_PERMISSION = CPermission.CAPTION_CLASS;

  /** 构件包前缀 */
  public static final String FUNCV_PREFIX = FVRumbaSystem.FUNCV_PREFIX;

  private String code;
  /** @deprecated */
  public static final String CAPTION_CODE = CPermission.CAPTION_CODE;
  /** @deprecated */
  public static final int LENGTH_code = CPermission.LENGTH_CODE;

  private String name;
  /** @deprecated */
  public static final String CAPTION_NAME = CPermission.CAPTION_NAME;
  /** @deprecated */
  public static final int LENGTH_name = CPermission.LENGTH_NAME;

  private String cartFuncViewUuid;

  private String remark;
  /** @deprecated */
  public static final String CAPTION_REMARK = CPermission.CAPTION_REMARK;
  /** @deprecated */
  public static final int LENGTH_remark = CPermission.LENGTH_REMARK;

  private PermissionProvider provider;

  private String fieldCaption;

  // private Set rolePermissions = new HashSet();
  // private Set userPermissions = new HashSet();

//  public static final String PERMISSION_EDIT = "权限.编辑权";/* "权限.编辑"; */
//  public static final String PERMISSION_VIEW = "权限.查看权";/* "权限.查看" */

  public String getCartFuncViewUuid() {
    return cartFuncViewUuid;
  }

  public void setCartFuncViewUuid(String cartUuid) throws StringTooLongException {
    if (cartUuid != null)
      cartUuid = truncate(cartUuid, CPermission.LENGTH_CARTFUNCVIEWUUID,
          "cartFuncViewUuid", CPermission.CAPTION_CARTFUNCVIEWUUID);
    this.cartFuncViewUuid = cartUuid;
  }

  public String getCode() {
    return code;
  }

  public void setCode(String code) throws StringTooLongException {
    if (code != null) {
      code = code.trim().toUpperCase();
      code = truncate(code, CPermission.LENGTH_CODE, "code", CPermission.CAPTION_CODE);
    }
    this.code = code;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) throws StringTooLongException {
    if (name != null) {
      name = truncate(name, CPermission.LENGTH_NAME, "name", CPermission.CAPTION_NAME);
    }
    this.name = name;
  }

  public String getRemark() {
    return remark;
  }

  public void setRemark(String remark) throws StringTooLongException {
    if (remark != null) {
      remark = truncate(remark, CPermission.LENGTH_REMARK, "remark",
          CPermission.CAPTION_REMARK);
    }
    this.remark = remark;
  }

  public String getFieldCaption() {
    return fieldCaption;
  }

  public void setFieldCaption(String fieldCaption) throws StringTooLongException {
    if (fieldCaption != null)
      fieldCaption = truncate(fieldCaption, CPermission.LENGTH_FIELDCAPTION,
          "fieldCaption", CPermission.CAPTION_FIELDCAPTION);
    this.fieldCaption = fieldCaption;
  }

  public PermissionProvider getProvider() {
    return provider;
  }

  public void setProvider(PermissionProvider provider) {
    this.provider = provider;
  }

  // private Set getRolePermissions() {
  // return rolePermissions;
  // }
  //
  // private void setRolePermissions(Set rolePermissions) {
  // this.rolePermissions = rolePermissions;
  // }
  //
  // private Set getUserPermissions() {
  // return userPermissions;
  // }
  //
  // private void setUserPermissions(Set userPermissions) {
  // this.userPermissions = userPermissions;
  // }
}
